package com.wanxi.util;

import sun.misc.BASE64Encoder;

import java.security.MessageDigest;
/**
 * @author 杨金乾
 */
public class Md5 {
    public static String encoderByMd5(String str){
        MessageDigest md5=null;
        try {
            md5=MessageDigest.getInstance("MD5");
            BASE64Encoder base64Encoder=new BASE64Encoder();
            return base64Encoder.encode(md5.digest(str.getBytes("UTF-8")));
        } catch (Exception e) {
            e.printStackTrace();
        }
        //如果try报异常，则默认一个密码aaaaaa
        return "C056Dl/oStNftflbn06seQ==";
    }
}
